<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象的扩展</title>
</head>
<body>
    <script>

        /* 
            1：对象的简写
         */
         let name = 'ls'
         let age = 18
         let obj1 = {
            name,
            age
         }

         /* 
            2: 属性表达式
          */
          // 在es5 中 key/value key是固定不变的
          let obj2a = {
              name: 'ls',
              age: 18
          }
          // 在es6 中支持key的变化
          let a = 'name'
          let b = 'age'
          let obj2b = {
              [a]:'ls',
              [b]:18
          }

          /* 
            3:对象的扩展
           */

           let obj3 = {
               name3:'ls',
               age3: 18,
               sex3: '男'
           }
           let {name3,...arg3} = obj3
           console.log(name3,arg3); // ls {age3: 18, sex3: '男'}

           /* 
            对象新增的方法
                Object.is(参数1,参数2):判断对象是否相等，相当于 === ，修复NaN不能于自己的问题

            */
            let obj4a = {name:'ls'}
            console.log(Object.is(1,1)); // true
            console.log(Object.is(obj4a,obj4a));// true
            console.log(Object.is({name:'ls'},{name:'ls'}));// false
            console.log(NaN === NaN); // false
            console.log(Object.is(NaN,NaN));// true
            let obj4b = {
                age: 18
            }
            let newObj4 = Object.assign(obj4a,obj4b)
            // console.log(newObj4);
            // console.log(obj4a);
            console.log(obj4a);
    </script>
</body>
</html>